﻿using System;
using System.Web;
using System.Web.Mvc;
using LaxCraft.Domain;


namespace LaxCraft.Helpers
{
    public static class SecurityHelper
    {
        public static bool PlayerAccess<TModel>(this HtmlHelper<TModel> source, Player player)
        {
            return PlayerAccess(player);
        }
        public static bool PlayerAccess(Player player)
        {
            try
            {
                return LaxCraftSession.CurrentUser.IsAdministrator || LaxCraftSession.CurrentUser.Player.Id == player.Id;
            }
            catch (Exception)
            {
                return false;
            }
        }

    }
}